package com.company.search;

/**
 * @author shenhan
 * @create 2020/2/2 17:58
 * @description
 */
public class SeqSearch {
    public static void main(String[] args) {
        int[] arr = {1, 9, 3, 11, -1, 89};
        final int i = seqSearch(arr, -1);
        System.out.println(i);
    }

    public static int seqSearch(int[] arr, int value) {
        // 线性查找是逐一比对
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == value) {
                return i;
            }
        }
        return -1;
    }
}
